# Contributor: Joe Searle <joe@jsearle.net>
# Maintainer: Joe Searle <joe@jsearle.net>
pkgname=mariadb-connector-odbc
pkgver=3.1.16
pkgrel=0
pkgdesc="MariaDB Connector/ODBC database driver"
url="https://github.com/MariaDB/mariadb-connector-odbc"
arch="all"
license="LGPL-2.1-only"
options="!check" # 'test' directory not included in releases
makedepends="cmake samurai openssl-dev unixodbc-dev mariadb-connector-c-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/MariaDB/mariadb-connector-odbc/archive/$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	# Link to /usr/include/mysql necessary when using system installed mariadb-connector-c
	CFLAGS="$CFLAGS -I/usr/include/mysql" \
		cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DUSE_SYSTEM_INSTALLED_LIB=True \
		-DWITH_SSL=OPENSSL \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove license files
	rm -rf "$pkgdir"/usr/docs
}

sha512sums="
f61041bcc14bcaf6caeb5b0b5c25edbdd8a9dacedb4e1c34c76c7d5c41a1bc89d90a2055c152d83b76531bd31d35ea96ed95854dac25cc55304827d3fe7dda46  mariadb-connector-odbc-3.1.16.tar.gz
"
